package models

// Competition 比赛信息表
type Competition struct {
	BaseModel
	Title               string  `gorm:"size:100;not null" json:"title"`
	CompetitionTime     string  `gorm:"size:100" json:"competition_time"`
	Location            string  `gorm:"size:255" json:"location"`
	Description         string  `gorm:"type:text" json:"description"`
	Image               string  `gorm:"size:255" json:"image"`
	Price               float64 `gorm:"type:decimal(10,2);default:0.00" json:"price"`
	MaxParticipants     int     `gorm:"default:0" json:"max_participants"`
	CurrentParticipants int     `gorm:"default:0" json:"current_participants"`
	RegistrationStart   string  `gorm:"size:100" json:"registration_start"`
	RegistrationEnd     string  `gorm:"size:100" json:"registration_end"`
	EventStart          string  `gorm:"size:100" json:"event_start"`
	EventEnd            string  `gorm:"size:100" json:"event_end"`
	EventLocation       string  `gorm:"size:255" json:"event_location"`
	EventAddress        string  `gorm:"type:text" json:"event_address"`
	CompetitionStatus   string  `gorm:"size:20;default:未开始" json:"competition_status"`
	Sort                int     `gorm:"default:0" json:"sort"`
	Status              int     `gorm:"default:1;comment:状态 1显示 0隐藏" json:"status"`
}

func (Competition) TableName() string {
	return "go_competition"
}

// CompetitionRegistration 比赛报名表
type CompetitionRegistration struct {
	BaseModel
	UserID            uint    `gorm:"not null;index" json:"user_id"`
	CompetitionID     uint    `gorm:"not null;index" json:"competition_id"`
	RegistrationNo    string  `gorm:"size:50;uniqueIndex" json:"registration_no"`
	ParticipantName   string  `gorm:"size:50" json:"participant_name"`
	ParticipantPhone  string  `gorm:"size:20" json:"participant_phone"`
	ParticipantIDCard string  `gorm:"size:50" json:"participant_id_card"`
	ParticipantAge    int     `gorm:"default:0" json:"participant_age"`
	ParticipantLevel  string  `gorm:"size:20" json:"participant_level"`
	Amount            float64 `gorm:"type:decimal(10,2);default:0.00" json:"amount"`
	Status            string  `gorm:"size:20;default:待确认" json:"status"`
	Remark            string  `gorm:"type:text" json:"remark"`

	// 关联
	User        User        `gorm:"foreignKey:UserID" json:"user,omitempty"`
	Competition Competition `gorm:"foreignKey:CompetitionID" json:"competition,omitempty"`
}

func (CompetitionRegistration) TableName() string {
	return "go_competition_registration"
}
